// 测试API调用的简单脚本
const axios = require('axios');

// 测试获取工艺流程详情API
async function testGetProcessFlowDetailById() {
  try {
    const processFlowId = 16; // 使用图片中显示的ID
    const url = 'http://localhost:5097/api/ProcessFlows/GetProcessFlowDetailById';
    
    console.log('正在调用API:', url);
    console.log('参数:', { processFlowId });
    
    const response = await axios.get(url, {
      params: { processFlowId }
    });
    
    console.log('API响应状态:', response.status);
    console.log('API响应数据:', JSON.stringify(response.data, null, 2));
    
    if (response.data && response.data.data) {
      const data = response.data.data;
      console.log('\n=== 基础信息 ===');
      console.log('ID:', data.id);
      console.log('工艺流程编码:', data.processCode || data.ProcessCode);
      console.log('工艺流程名称:', data.processName || data.ProcessName);
      console.log('负责人ID:', data.responsibleId || data.ResponsibleId);
      console.log('负责人姓名:', data.responsibleName || data.ResponsibleName);
      console.log('部门ID:', data.departmentId || data.DepartmentId);
      console.log('部门名称:', data.departmentName || data.DepartmentName);
      
      console.log('\n=== 工序操作 ===');
      const operations = data.processOperations || data.ProcessOperations || data.operations || [];
      console.log('工序数量:', operations.length);
      operations.forEach((op, index) => {
        console.log(`工序 ${index + 1}:`, {
          id: op.id,
          operationId: op.operationId,
          processId: op.processId,
          operationCode: op.operationCode,
          operationName: op.operationName,
          remark: op.remark
        });
      });
    }
    
  } catch (error) {
    console.error('API调用失败:', error.message);
    if (error.response) {
      console.error('响应状态:', error.response.status);
      console.error('响应数据:', error.response.data);
    }
  }
}

// 运行测试
testGetProcessFlowDetailById(); 